package io.filecopy;

import java.util.Arrays;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.xml.sax.SAXException;

public class FileCopy {

  public static void main(String[] args) throws IOException, XPathExpressionException, SAXException, ParserConfigurationException {
    File xmlFile = new File("filecopy.xml");
    if (args.length > 0){
      xmlFile = new File(args[0]);
    }
    System.out.println("Config File: " + xmlFile.getAbsolutePath());
    XMLSerializer xml = new XMLSerializer();
    InputStream fileIn = new FileInputStream(xmlFile);
    JobDescription[] jobs = xml.fromStream(fileIn, xmlFile.getParentFile());
    fileIn.close();
    System.out.println(Arrays.toString(jobs));
  }
}
